{% extends "base.html" %}
{% load friendly_time %}
{% load running_status %}
{% load problem_index %}
{% block page_title %}{% block asgn_page_title%}{% endblock %} - {{ asgn.name }} - 作业库 - {% endblock %}
{% block page_head %}
    {% block asgn_page_head %}{% endblock %}
{% endblock %}
{% block page_body %}
<div class="header_container">
<h1>作业：{{ asgn.name }}&nbsp;
<small>
    / {{ asgn.course.name }}
</small>
</h1>
</div>
<div class="page_container">
    <div class="row">
        <div class="col-sm-3">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">作业信息</h3>
                </div>
                 {% if permission.1 == 0 %}
                <div class="panel-body alert-warning">作业将在<span id="remaining_time"></span>后截止</div>
                {% elif permission.1 == 1 %}
                <div class="panel-body alert-danger">作业已结束</div>
                {% elif permission.1 == -1 %}
                <div class="panel-body alert-info">作业未开始</div>
                {% elif permission.1 == 2 or permission.1 == 3 %}
                     {% if permission.2 != None %}
                <div class="panel-body alert-info">待批改：{{ permission.2 }}人</div>
                    {% endif %}
                {% endif %}
                <div class="list-group">
                    <li class="list-group-item">作业名称：{{ asgn.name }}</li>
                    <li class="list-group-item">最高得分：{{ asgn.full_score }}</li>
                    <li class="list-group-item">
                        {% if 'all' in asgn.lang or 'gcc' in asgn.lang %}<span class="glyphicon glyphicon-ok"></span>{% else %}<span class="glyphicon glyphicon-remove"></span>{% endif %} C语言
                        {% if 'all' in asgn.lang or 'gcc-cpp' in asgn.lang %}<span class="glyphicon glyphicon-ok"></span>{% else %}<span class="glyphicon glyphicon-remove"></span>{% endif %} C++
                        {% if 'all' in asgn.lang or 'java' in asgn.lang %}<span class="glyphicon glyphicon-ok"></span>{% else %}<span class="glyphicon glyphicon-remove"></span>{% endif %} Java
                    </li>
                </div>
            </div>
            <!--题目列表-->
            {% if permission.1 != -1 or user_session.user_role == 2  or user_session.user_role == 99 %}
            {% if problem_list != None %}
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">题目列表</h3>
                </div>
                <div class="list-group">
                    {% for p in problem_list %}
                    <a href="{% url 'asgn_show_asgn_problem' asgn.id p.id %}" class="list-group-item {% if problem.id == p.problem.id %}active{% endif %}">
                        {% if asgn != None and asgn.hideProblemTitle %}
                            题目{{ p.index | problem_index }}
                        {% else %}

                            {% if asgn.hideProblemId %}
                                {{ p.index | problem_index }}
                            {% else %}
                                {{ p.problem.id }}
                            {% endif %}.

                            {{ p.problem.title }}

                        {% endif %}
                    </a>
                    {% empty %}
                    <a class="list-group-item">还没有设置题目</a>
                    {% endfor %}
                </div>
            </div>
            {% endif %}
            {% endif %}
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">功能导航</h3>
                </div>
                <div class="list-group">
                    <a href="{% url "asgn_problem_list" asgn.id %}" class="list-group-item {% if type == 'list' %}active{% endif %}"><span class="glyphicon glyphicon-th-list"></span>&nbsp;题目列表</a>
                    {% if user_session.user_role == 1  %}
                    {% if permission.1 < 2 %}
                    <a href="{% url "asgn_show_report" asgn.id user_session.user_id %}" class="list-group-item {% if type == 'report' %}active{% endif %}">
                        <span class="glyphicon glyphicon-list-alt"></span>&nbsp;实验报告
                    </a>
                    {% endif %}
                    {% endif %}
                    <a href="{% url 'asgn_status_list' asgn.id %}" class="list-group-item {% if type == 'status' %}active{% endif %}"><span class="glyphicon glyphicon-tasks"></span>&nbsp;评测状态</a>
                    <a class="list-group-item {% if type == 'ranklist' %}active{% endif %}" href="{% url 'asgn_rank_list' asgn.id %}"><span class="glyphicon glyphicon-sort-by-attributes-alt"></span>&nbsp;排行榜</a>
                    <a class="list-group-item" href="{% url 'asgn_rank_board' asgn.id %}" target="_blank"><span class="glyphicon glyphicon-open"></span>&nbsp;滚动排行榜(测试)</a>
                    <a class="list-group-item {% if type == 'answer' %}active{% endif %}" href="{% url 'asgn_answer_view' asgn.id %}"><span class="glyphicon glyphicon-send"></span>&nbsp;参考答案</a>
                </div>
            </div>
            {% if permission.1 >= 2 or user_session.user_role == 2 or user_session.user_role == 99 %}
            <div class="panel panel-warning">
                <div class="panel-heading">
                <h3 class="panel-title">管理功能</h3>
                </div>
                <div class="list-group">
                    {% if permission.1 == 2 or user_session.user_role == 2 or user_session.user_role == 99  %}
                    <a class="list-group-item" href="{% url 'problem_archive' %}?asgn_id={{ asgn.id }}" target="_blank"><span class="glyphicon glyphicon-plus"></span>&nbsp;增加题目</a>
                    <a class="list-group-item {% if type == 'setting' %}active{% endif %}" href="{% url 'asgn_mgr_asgn_setting' asgn.id %}"><span class="glyphicon glyphicon-cog"></span>&nbsp;作业设置</a>
                    {% endif %}
                    <a class="list-group-item {% if type == 'checkup' %}active{% endif %}" href="{% url "asgn_mgr_show_asgn_checkup_list" asgn.id %}"><span class="glyphicon glyphicon-check"></span>&nbsp;作业批改</a>
                    {% if permission.1 == 2 or user_session.user_role == 2 or user_session.user_role == 99  %}
                    <a class="list-group-item {% if type == 'arrangement' %}active{% endif %}" href="{% url 'asgn_mgr_asgn_arrangement' asgn.id %}"><span class="glyphicon glyphicon-lock"></span>&nbsp;访问权限管理</a>
                    <a class="list-group-item {% if type == 'visit_reqire' %}active{% endif %}" href="{% url 'asgn_mgr_asgn_visit_require' asgn.id %}"><span class="glyphicon glyphicon-retweet"></span>&nbsp;学生调课管理</a>
                    <a class="list-group-item {% if type == 'statistics' %}active{% endif %}" href="{% url 'asgn_statistics' asgn.id %}"><span class="glyphicon glyphicon-stats"></span>&nbsp;作业统计分析</a>
                    {% endif %}
                    <a class="list-group-item {% if type == 'zip_code' %}active{% endif %}" href="{% url 'asgn_mgr_zip_code_config' asgn.id %}"><span class="glyphicon glyphicon-save"></span>&nbsp;作业代码打包</a>
                    {% if permission.1 == 2 or user_session.user_role == 2 or user_session.user_role == 99  %}
                    <a class="list-group-item {% if type == 'delete' %}active{% endif %}" href="{% url 'asgn_mgr_delete_view' asgn.id %}"><span class="glyphicon glyphicon-trash"></span>&nbsp;删除作业</a>
                    {% endif %}
                </div>
            </div>
            {% endif %}
        </div>
        <div class="col-sm-9">
            {% block asgn_page_body %}{% endblock %}
        </div>
    </div>
</div>
<br />
{% endblock %}
{% block page_script %}
    <script type="text/javascript">
    $(function () {
        {% if permission.1 == 0 %}
        WeJudge.set_countdown_timer('{{ permission.2 }}', "#remaining_time");
        {% endif %}
    })
    </script>
    {% block asgn_page_script %}{% endblock %}
{% endblock %}